package com.ht.medicaltreatment.viewmodel

import androidx.lifecycle.viewModelScope
import com.blankj.utilcode.util.ToastUtils
import com.ht.medicaltreatment.bean.BloodOrderDetailBean
import com.ht.medicaltreatment.bean.Drawblood
import com.ht.medicaltreatment.bean.PatientFormBean
import com.ht.medicaltreatment.bean.WanDaiBean
import com.xgst.lib.http.ApiResult
import kotlinx.coroutines.launch

class BloodOrderListViewModel : BaseViewModel() {

    fun request(id:String,onSuccess:(WanDaiBean)->Unit){
        viewModelScope.launch {
            val bean =  mApi.caixueDetail(id)
            when(bean){
                is ApiResult.Success -> onSuccess(bean.data.data!!)
                is ApiResult.Error -> ToastUtils.showShort(bean.errorMessage)
            }
        }
    }

    fun orderList(patientId:String,onSuccess:(MutableList<PatientFormBean>?)->Unit){
        viewModelScope.launch {
            val bean = mApi.patientId(patientId)
            when(bean){
                is ApiResult.Success -> onSuccess(bean.data.data)
                is ApiResult.Error -> ToastUtils.showShort(bean.errorMessage)
            }
        }
    }
}
